package sg.techstudio.suntec.serialize;

import java.io.IOException;
import java.text.ParseException;
import java.util.Date;

import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.DeserializationContext;
import org.codehaus.jackson.map.JsonDeserializer;

public class CustomJsonDateDeserializer extends JsonDeserializer<Date> {

	@Override
	public Date deserialize(JsonParser parser, DeserializationContext deser)
			throws IOException, JsonProcessingException {
		String date = parser.getText();
		try {
            return CustomJsonDateSerializer.JSON_DATEFORMAT.parse(date);
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
	}

}
